//
//  UIViewController+AYExtension.m
//  MettingBar
//
//  Created by AY on 16/5/23.
//  Copyright © 2016年 FCPlay. All rights reserved.


//  实现此分类可以将系统的"dealloc"方法交换为自己的"ay_dealloc"方法,方便监听控制器的销毁
//  也不妨碍在控制器内调用"dealloc"

#import "UIViewController+AYExtension.h"
#import <objc/runtime.h>

@implementation UIViewController (AYExtension)

+ (void)load
{
    Method method1 = class_getInstanceMethod(self, NSSelectorFromString(@"dealloc"));
    Method method2 = class_getInstanceMethod(self, @selector(ay_dealloc));
    method_exchangeImplementations(method1, method2);
}

- (void)ay_dealloc
{
    NSLog(@"%@ - ay_dealloc", self);
    
    [self ay_dealloc];
}

@end
